#include "StdAfx.h"
#include <afxmt.h>

#include "Alogmfc.h"

static CString mfilename=_T("alogmfc.txt");
static CCriticalSection mcriticals;
static int mfilecnt =0;

static int mcreatesign = 0x12345678;
bool Alogmfc::check()
{
	return ( mcreatesign == 0x12345678 ) ? true : false;
}
void Alogmfc::out(CString str)
{
#ifdef _DEBUG
	TRACE(str);
#endif
}
void Alogmfc::fout(CString str)
{
	if( !check()) return;

	mcriticals.Lock();

	CStdioFile	file;
	bool isok = false;
	if( mfilecnt == 0)
		isok = file.Open( mfilename, CFile::typeText | CFile::modeCreate 
			| CFile::modeReadWrite );
	else
		isok = file.Open( mfilename, CFile::typeText | CFile::modeCreate 
			| CFile::modeNoTruncate | CFile::modeReadWrite);
	if( isok)
	{
		mfilecnt = 1;
		file.WriteString(str);
		file.Close();
	}

	mcriticals.Unlock();
}
void Alogmfc::dialog(CString str)
{
	MessageBox(NULL, str, _T("Infomation"), MB_OK | MB_ICONWARNING);
}
